/*
package com.example.springexercise.demos.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.sql.SQLOutput;

@RestController
public class FileUploadController1 {
    //获取当前工作目录
    private static final String UPLOADED_FOLDER =  System.getProperty("user.dir")+"/upload/";
    @GetMapping("/up")
    public String handleGetRequest() {
        // 处理 GET 请求的逻辑
        return "GET 请求成功";
    }
    @PostMapping("/up")
    public String upload(String nickname, MultipartFile f) throws IOException{
        System.out.println("文件大小"+f.getSize());
        System.out.println(f.getContentType());
        System.out.println(f.getOriginalFilename());
        System.out.println(System.getProperty("user.dir"));  // 打印输出了用户目录
        saveFile(f);// 将上传文件保存到指定的文件夹中
        return "上传成功";
    }
    public void saveFile(MultipartFile f) throws IOException{
        File upDir = new File(UPLOADED_FOLDER);
        if(!upDir.exists()){
            upDir.mkdir();
        }
        File file = new File(UPLOADED_FOLDER + f.getOriginalFilename());
        f.transferTo(file);
    }
}
*/
